# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.


class Author(models.Model):
    """
    作者信息表
    """
    author_name = models.CharField(max_length=24, verbose_name=u'作者姓名')
    # head_image = models.ImageField(upload_to='', verbose_name=u'作者头像')
    head_image = models.URLField(default=None, verbose_name=u'作者头像')
    sex = models.IntegerField(choices=((0, '男'), (1, '女')), default=0, verbose_name=u'性别')
    occupation = models.CharField(max_length=36, verbose_name=u'职位介绍')
    synopsis = models.TextField(default=u'这个人不懒，但也没留下什么...', verbose_name=u'个人简介')
    born_time = models.DateTimeField(verbose_name=u'出生日期')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name=u'注册时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name=u'更新时间')

    def __unicode__(self):
        return self.author_name

    class Meta:
        verbose_name = u'作者信息'
        verbose_name_plural = verbose_name


class AuthorContact(models.Model):
    """
    作者外链表
    如： githut 码云等等的联系方式
    """
    author_id = models.ForeignKey(Author)
    contact_name = models.CharField(max_length=12, verbose_name=u'联系方式名称')
    contact_addr = models.URLField(blank=True, verbose_name=u'分流地址')
    is_use = models.IntegerField(choices=((0, u'启用'), (1, '不启用')), default=0, verbose_name=u'是否启用')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name=u'创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name=u'更新时间')

    def __unicode__(self):
        return self.contact_name

    class Meta:
        verbose_name = u'分流信息'
        verbose_name_plural = verbose_name
        unique_together = ('author_id', 'contact_name')
